package com.ag.answergames.controller;

import com.ag.answergames.service.answerlog.AnswerLogService;
import com.ag.answergames.vo.AnswerLogVO;
import com.ag.answergames.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AnswerLogController {

    @Autowired
    AnswerLogService answerLogService;

    @PostMapping("/getAnswerLogData")
    public Result<AnswerLogVO> getCount(@RequestParam String openId, @RequestParam int dateType) {
        Long all = answerLogService.getTotalCount(openId, dateType);
        Long correct = answerLogService.getCorrectCount(openId, dateType);
        return Result.success(
                new AnswerLogVO(all, (double) correct / all));
    }

}
